import 'dart:io';
import 'dart:developer';
import 'package:flutter/material.dart';  //
import 'package:get/get.dart';
import 'app/routes/app_pages.dart';
import 'package:flutter/services.dart';
import 'package:flutter_localizations/flutter_localizations.dart';

import 'config/localizations.dart';

Future<void> main() async {
  if (Platform.isAndroid) {
    // 设置Appbar上面的电池显示的状态栏的背景与颜色
    SystemUiOverlayStyle systemUiOverlayStyle =
    const SystemUiOverlayStyle(statusBarColor: Colors.transparent);
    SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
    // SystemChrome.setEnabledSystemUIOverlays([]); //隐藏状态栏
  }
  WidgetsFlutterBinding.ensureInitialized();
  SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp])
      .then((_) {
    runApp(
      GetMaterialApp(
        debugShowCheckedModeBanner: false,
        title: "词卡闪记",//
        theme: ThemeData(platform: TargetPlatform.iOS,),
        initialRoute: AppPages.INITIAL,
        getPages: AppPages.routes,
        /// 国际化
        locale: Get.deviceLocale,/// 跟随手机系统语言
        translations: Messages(),/// 导入国际化字典
        fallbackLocale: const Locale('en', 'US'),/// 在配置错误时使用的语言
        localizationsDelegates: const [
          GlobalMaterialLocalizations.delegate,
          GlobalWidgetsLocalizations.delegate,
          GlobalCupertinoLocalizations.delegate,
        ],
        supportedLocales: const [
          Locale('zh', 'CN'),
          Locale('en', 'US'),
        ],
      ),
    );
  });

}